package com.blrs.service.project.servicelog.impl;

import java.util.List;

import com.blrs.common.exception.ServiceException;
import com.blrs.common.utils.DateUtils;
import com.blrs.common.utils.StringUtils;
import com.blrs.domain.StageServiceLog;
import com.blrs.mapper.StageServiceLogMapper;
import com.blrs.service.project.servicelog.IStageServiceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 阶段服务日志Service业务层处理
 * 
 * @author guobin
 * @date 2025-01-10
 */
@Service
public class StageServiceLogServiceImpl implements IStageServiceLogService
{
    @Autowired
    private StageServiceLogMapper stageServiceLogMapper;

    /**
     * 查询阶段服务日志
     * 
     * @param id 阶段服务日志主键
     * @return 阶段服务日志
     */
    @Override
    public StageServiceLog selectStageServiceLogById(String id)
    {
        return stageServiceLogMapper.selectStageServiceLogById(id);
    }

    /**
     * 查询阶段服务日志列表
     * 
     * @param stageServiceLog 阶段服务日志
     * @return 阶段服务日志
     */
    @Override
    public List<StageServiceLog> selectStageServiceLogList(StageServiceLog stageServiceLog)
    {
        return stageServiceLogMapper.selectStageServiceLogList(stageServiceLog);
    }

    /**
     * 新增阶段服务日志
     * 
     * @param stageServiceLog 阶段服务日志
     * @return 结果
     */
    @Override
    public int insertStageServiceLog(StageServiceLog stageServiceLog)
    {
        return stageServiceLogMapper.insertStageServiceLog(stageServiceLog);
    }

    /**
     * 修改阶段服务日志
     * 
     * @param stageServiceLog 阶段服务日志
     * @return 结果
     */
    @Override
    public int updateStageServiceLog(StageServiceLog stageServiceLog)
    {
        stageServiceLog.setUpdateTime(DateUtils.getNowDate());
        return stageServiceLogMapper.updateStageServiceLog(stageServiceLog);
    }

    /**
     * 批量删除阶段服务日志
     * 
     * @param ids 需要删除的阶段服务日志主键
     * @return 结果
     */
    @Override
    public int deleteStageServiceLogByIds(String[] ids)
    {
        return stageServiceLogMapper.deleteStageServiceLogByIds(ids);
    }

    /**
     * 根据项目ID删除服务日志
     *
     * @param projectId 项目ID
     * @return 结果
     */
    @Override
    public int deleteStageServiceLogByProjectId(String projectId) {
        if (StringUtils.isEmpty(projectId)) {
            throw new ServiceException("项目ID不能为空");
        }
        return stageServiceLogMapper.deleteStageServiceLogByProjectId(projectId);
    }

    /**
     * 删除阶段服务日志信息
     * 
     * @param id 阶段服务日志主键
     * @return 结果
     */
    @Override
    public int deleteStageServiceLogById(String id)
    {
        return stageServiceLogMapper.deleteStageServiceLogById(id);
    }
}
